package com.ruoyi.web.controller.wechat;

import com.ruoyi.common.constant.wechat.WechatConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信小程序部门
 *
 * @author jiexiang.sun/Jason
 * @version 1.0.0
 * @create 2022-03-06 16:37
 **/
@RestController
@Validated
@RequestMapping("/wechat/dept")
public class WechatDeptController extends BaseController {

    @Autowired
    private ISysDeptService sysDeptService;

    /**
     * 获取部门下拉树列表
     */
    @GetMapping("treeselect")
    public AjaxResult treeselect(@RequestAttribute(name = WechatConstants.WECHAT_TOKEN_USER_DEPTID) Long deptId) {
        return AjaxResult.success(sysDeptService.treeselect(deptId));
    }

    /**
     * 获取用户部门下一级子部门
     *
     * @param deptId
     * @return
     */
    @GetMapping("getSubList")
    public AjaxResult getSubList(@RequestAttribute(name = WechatConstants.WECHAT_TOKEN_USER_DEPTID) Long deptId) {
        return AjaxResult.success(sysDeptService.getSubList(deptId));
    }
}
